<template>
  <div class="el-menu-item-group">
    <template v-for="(item,i) in menuList">
      <el-menu-item v-if="item.children.length===0" @click="ClickMenu(item)" :key="i" :route="item.path" :index="item.path">
        <i :class="item.icon"></i>
        <span slot="title">{{item.name}}</span>
      </el-menu-item>
      <el-submenu v-if="item.children.length>0" :index="item.path" :route="item.path" :key="item.menu_id">
        <template slot="title">
          <i :class="item.icon"></i>
          <span slot="title"> {{item.name}}</span>
        </template>
        <NavMenu :menuList="item.children"></NavMenu>
      </el-submenu>
    </template>
  </div>
</template>

<script>
  import {mapState} from 'vuex';

  export default {
    name: 'NavMenu',
    props: {
      menuList: {
        type: Array,
        default: []
      }
    },
    data() {
      return {}
    },
    computed: {},
    methods: {
      ClickMenu(obj) {
        /* this.$store.commit('ADD_TOP_NAV',obj);*/
      },
    }
  }
</script>

<style lang="stylus" rel="stylesheet/stylus">

</style>
